package com.cldz.controller;

import com.cldz.common.dto.res.FsuAlarmResDto;
import com.cldz.service.FsuAlarmService;
import com.cldz.response.support.ServerResponse;
import com.cldz.common.dto.req.FsuAlarmDto;
import com.cldz.feign.FsuAlarmFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @ Author     ：lixiao.
 * @ Date       ：Created in 13:44 2018/12/22
 * @ Description：
 * @ Modified By：
 */
@Slf4j
@RestController
public class FsuAlarmController implements FsuAlarmFeign {

    @Autowired
    private FsuAlarmService fsuAlarmService;

    /**
     * 获取指定设备实时告警(FSU)
     * @param fsuAlarmDto
     * @return
     */
    @GetMapping("/fsuSuIDRunAlarmData")
    public ServerResponse getFsuSuIDRunAlarmData(FsuAlarmDto fsuAlarmDto){
        List<FsuAlarmResDto> fsuSuIDRunAlarmData = fsuAlarmService.getFsuSuIDRunAlarmData(fsuAlarmDto);
        Integer fsuSuIDRunAlarmDataAmount = fsuAlarmService.getFsuSuIDRunAlarmDataAmount(fsuAlarmDto);
        return ServerResponse.createDataAndCount(fsuSuIDRunAlarmDataAmount,fsuSuIDRunAlarmData);
    }

    /**
     * 获取指定设备历史告警(FSU)
     * @param fsuAlarmDto
     * @return
     */
    @GetMapping("/fsuSuIDHisAlarmData")
    public ServerResponse getFsuSuIDHisAlarmData(FsuAlarmDto fsuAlarmDto){
        List<FsuAlarmResDto> fsuSuIDRunAlarmData = fsuAlarmService.getFsuSuIDHisAlarmData(fsuAlarmDto);
        Integer fsuSuIDRunAlarmDataAmount = fsuAlarmService.getFsuSuIDHisAlarmDataAmount(fsuAlarmDto);
        return ServerResponse.createDataAndCount(fsuSuIDRunAlarmDataAmount,fsuSuIDRunAlarmData);
    }

    /**
     * 获取全部设备实时告警(FSU)
     * @param fsuAlarmDto
     * @return
     */
    @GetMapping("/fsuAllRunAlarmData")
    public ServerResponse getFsuAllRunAlarmData(FsuAlarmDto fsuAlarmDto){
        List<FsuAlarmResDto> fsuSuIDRunAlarmData = fsuAlarmService.getFsuAllRunAlarmData(fsuAlarmDto);
        Integer fsuSuIDRunAlarmDataAmount = fsuAlarmService.getFsuAllRunAlarmDataAmount(fsuAlarmDto);
        return ServerResponse.createDataAndCount(fsuSuIDRunAlarmDataAmount,fsuSuIDRunAlarmData);
    }

    /**
     * 获取全部设备历史告警(FSU)
     * @param fsuAlarmDto
     * @return
     */
    @GetMapping("/fsuHisAlarmData")
    public ServerResponse getFsuHisAlarmData(FsuAlarmDto fsuAlarmDto){
        List<FsuAlarmResDto> data = fsuAlarmService.getFsuHisAlarmData(fsuAlarmDto);
        Integer amount = fsuAlarmService.getFsuHisAlarmDataAmount(fsuAlarmDto);
        return ServerResponse.createDataAndCount(amount,data);
    }


    /**
     * 获取设备实时告警数量FSU（多个设备）
     * @param fsuAlarmDto
     * @return
     */
    @GetMapping("/fsuRunAlarmCount")
    public ServerResponse getFsuRunAlarmCount(FsuAlarmDto fsuAlarmDto){
        List<Map<String,Object>> list = fsuAlarmService.getFsuRunAlarmCount(fsuAlarmDto);
        return ServerResponse.createDataList(list);
    }

    /**
     * 获取设备历史告警数量FSU（多个设备）
     * @param fsuAlarmDto
     * @return
     */
    @GetMapping("/fsuHisAlarmCount")
    public ServerResponse getFsuHisAlarmCount(FsuAlarmDto fsuAlarmDto){
        List<Map<String,Object>> list = fsuAlarmService.getFsuHisAlarmCount(fsuAlarmDto);
        return ServerResponse.createDataList(list);
    }


}
